import { Pipe, PipeTransform } from '@angular/core';
import { Utils } from '../../index';

@Pipe({
    name: 'minuteSecond'
})
export class MinuteSecondPipe implements PipeTransform {

    transform(value: number, args?: any): any {
        if (value && Utils.isNumber(value)) {
            const minute = Math.floor(value / 60);
            const second = (value % 60);
            if (second < 10) {
                return `${minute}:0${Math.floor(second)}`;
            } else {
                return `${minute}:${Math.floor(second)}`;
            }
        } else {
            return '0:00';
        }
    }

}
